package com.atguigu.springcloud.controller;

import com.atguigu.springcloud.entities.CommonResult;
import com.atguigu.springcloud.entities.Payment;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.UUID;

/**
 * @Author : 李红磊
 * @Date : 2021/05/27/12:26
 * @Description :
 */
@RestController
@Slf4j
public class PaymentController {

    @Value("${server.port}")
    private String serverPort;


    public static HashMap<Long, Payment> map=new HashMap<>();

    static {
        map.put(1L,new Payment(1L, UUID.randomUUID().toString().substring(0,6)));
        map.put(2L,new Payment(2L, UUID.randomUUID().toString().substring(0,6)));
        map.put(3L,new Payment(3L, UUID.randomUUID().toString().substring(0,6)));
    }


    @GetMapping("/paymentSQL/{id}")
    public CommonResult<Payment> paymentSQL(@PathVariable("id")Long id){

        Payment payment = map.get(id);

        return new CommonResult<>(200,"from serverPort\t"+serverPort,payment);
    }


}
